package com.woniuxy.service.impl;

import com.woniuxy.dao.RbacManagerDao;
import com.woniuxy.pojo.RbacManager;
import com.woniuxy.pojo.ResponseEntity;
import com.woniuxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

public class UserServiceImpl implements UserService {
    @Autowired
    RbacManagerDao rbacManagerDao;

    @Override
    public ResponseEntity addOne(RbacManager rbacManager) {
        int i = rbacManagerDao.addOne(rbacManager);
        if (i > 0) {
            return ResponseEntity.SUCCESSFUL;
        } else {
            return ResponseEntity.FAIL;
        }
    }

    @Override
    public ResponseEntity deleteOne(int id) {
        int i = rbacManagerDao.deleteOne(id);
        if (i > 0) {
            return ResponseEntity.SUCCESSFUL;
        } else {
            return ResponseEntity.FAIL;
        }
    }

    @Override
    public ResponseEntity updateManager(RbacManager rbacManager) {
        int i = rbacManagerDao.updateOne(rbacManager);
        if (i > 0) {
            return ResponseEntity.SUCCESSFUL;
        } else {
            return ResponseEntity.FAIL;
        }
    }

    @Override
    public ResponseEntity findOne(int id) {
        RbacManager rbacManager = rbacManagerDao.findOne(id);
        return new ResponseEntity<RbacManager>(200, "查询成功", rbacManager);
    }

    @Override
    public ResponseEntity findAll() {
        return new ResponseEntity<>(200, "查询成功", rbacManagerDao.findAll());
    }
}

